From 77c061bc0b8aecce7311ce820b3401c95797a589 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sun, 11 Apr 2021 11:40:44 -0700 Subject: working raw paste fetch --- frontend/src/pages/raw/[hash].js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 frontend/src/pages/raw/[hash].js (limited to 'frontend/src/pages/raw/[hash].js') diff --git a/frontend/src/pages/raw/[hash].js b/frontend/src/pages/raw/[hash].js new file mode 100644 index 0000000..d0a66a7 --- /dev/null +++ b/frontend/src/pages/raw/[hash].js @@ -0,0 +1,24 @@ +import React from 'react'; +import resolvePaste from "../../http/useFetchPaste"; +import {CodeLike} from "../../components/Common/mixins"; +import styled from 'styled-components' + +const RawText = styled.pre` + ${CodeLike} + padding: 0 1em; +` + +export async function getServerSideProps(ctx) { + const data = await resolvePaste(ctx.params.hash) + + // Pass data to the page via props + return { props: { ...data } } +} + +const Raw = ({error, data}) => { + return + {data?.content || error} + +} + +export default Raw \ No newline at end of file -- cgit v1.2.3 From 12c995b6bd501be73b60e3bae6c46c59cebef6c2 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sun, 11 Apr 2021 12:30:02 -0700 Subject: base resolve paste and fetch paste refactor --- frontend/src/pages/raw/[hash].js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'frontend/src/pages/raw/[hash].js') diff --git a/frontend/src/pages/raw/[hash].js b/frontend/src/pages/raw/[hash].js index d0a66a7..a100b4b 100644 --- a/frontend/src/pages/raw/[hash].js +++ b/frontend/src/pages/raw/[hash].js @@ -1,5 +1,5 @@ import React from 'react'; -import resolvePaste from "../../http/useFetchPaste"; +import resolvePaste from "../../http/resolvePaste"; import {CodeLike} from "../../components/Common/mixins"; import styled from 'styled-components' -- cgit v1.2.3 From d58c7a3ad5dc83a08e040a855f158f8c6c09e154 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sun, 11 Apr 2021 13:50:20 -0700 Subject: password resolution, dynamic head --- frontend/src/pages/raw/[hash].js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'frontend/src/pages/raw/[hash].js') diff --git a/frontend/src/pages/raw/[hash].js b/frontend/src/pages/raw/[hash].js index a100b4b..3374eea 100644 --- a/frontend/src/pages/raw/[hash].js +++ b/frontend/src/pages/raw/[hash].js @@ -2,6 +2,7 @@ import React from 'react'; import resolvePaste from "../../http/resolvePaste"; import {CodeLike} from "../../components/Common/mixins"; import styled from 'styled-components' +import NextHead from "../../components/NextHead"; const RawText = styled.pre` ${CodeLike} @@ -10,15 +11,17 @@ const RawText = styled.pre` export async function getServerSideProps(ctx) { const data = await resolvePaste(ctx.params.hash) - - // Pass data to the page via props + console.log(data) return { props: { ...data } } } const Raw = ({error, data}) => { - return - {data?.content || error} - + return <> + {!error && } + + {data?.content || error} + + } export default Raw \ No newline at end of file -- cgit v1.2.3 From dc3f74c642be4dab8ce5507a444ba93371527e78 Mon Sep 17 00:00:00 2001 From: jackyzha0 Date: Sun, 11 Apr 2021 14:55:54 -0700 Subject: fix broken multiline --- frontend/src/pages/raw/[hash].js | 1 - 1 file changed, 1 deletion(-) (limited to 'frontend/src/pages/raw/[hash].js') diff --git a/frontend/src/pages/raw/[hash].js b/frontend/src/pages/raw/[hash].js index 3374eea..9edde36 100644 --- a/frontend/src/pages/raw/[hash].js +++ b/frontend/src/pages/raw/[hash].js @@ -11,7 +11,6 @@ const RawText = styled.pre` export async function getServerSideProps(ctx) { const data = await resolvePaste(ctx.params.hash) - console.log(data) return { props: { ...data } } } -- cgit v1.2.3